package com.audaque.springboot.foshanupload.web.docdemo.controller;


import cn.hutool.core.bean.BeanUtil;
import com.audaque.springboot.foshanupload.doc.component.ItextpdfProvider;
import com.audaque.springboot.foshanupload.web.docdemo.model.bo.DocTemplateBo;
import com.audaque.springboot.foshanupload.web.docdemo.model.req.AlarmInstanceReq;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.Map;
import java.util.UUID;

@RestController
@Slf4j
@Api(value = "ItextpdfController 前端控制器")

@RequestMapping("/itextpdf")
public class ItextpdfController {

    @Autowired
    private ItextpdfProvider itextpdfProvider;


    @PostMapping("exportExcel")
    @ApiOperation(value = "导出excel")
    public void export(@RequestBody AlarmInstanceReq req, HttpServletResponse response) throws Exception {
        //生成文档
        //文档数据
        String busName="";
        DocTemplateBo docTemplateBo = new DocTemplateBo();
        Map<String, Object> stringObjectMap = BeanUtil.beanToMap(docTemplateBo);
        String docName = UUID.randomUUID().toString() + "_" + busName + ".pdf";
        String filePath = "";
        itextpdfProvider.generator(stringObjectMap, "html/template_freemarker.html", "css/template_freemarker.css", filePath);
    }


}
